package com.GLM.Viewer.Friends;


import com.GLM.Viewer.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.NavUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;


public class FriendsMainActivity extends Activity {
	Animation mAnimRightIn ;
	Animation mAnimDownIn;
	boolean isShow = true;
	View friendsView;
	View tempView;
	EditText searchEditText;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.view_friends_main);
	
		friendsView = (View)findViewById(R.id.viewfriends_main_layout);
		tempView = (View)findViewById(R.id.viewfriends_main_layout2);
		mAnimDownIn = AnimationUtils.loadAnimation(FriendsMainActivity.this, R.anim.anim_down_in);
		friendsView.setAnimation(mAnimDownIn);
		
	}

	public void goBackButton_OnClick(View v) {
		NavUtils.navigateUpFromSameTask(this);
	}
	
	public void myFriends_OnClick(View v){
		Intent intent = new Intent(FriendsMainActivity.this,FriendsAttentionActivity.class);
		startActivity(intent);
	}
	
	public void MyGroups_OnClick(View v){
		Intent intent = new Intent(FriendsMainActivity.this,FriendsGroupsActivity.class);
		startActivity(intent);
	}
	
	public void MySMS_OnClick(View v){
		Intent intent = new Intent(FriendsMainActivity.this,FriendsSMSActivity.class);
		startActivity(intent);
	}
	
	public void MyFriendsSearch_OnClick(View v){
		View searchView = (View)findViewById(R.id.friends_SearchView);
		searchEditText = (EditText)searchView.findViewById(R.id.searchEditText);
		TextView tipsView = (TextView)searchView.findViewById(R.id.TipsTextview);
		mAnimRightIn = AnimationUtils.loadAnimation(FriendsMainActivity.this, R.anim.anim_right_in);
		Animation mAnimDownin2 = AnimationUtils.loadAnimation(FriendsMainActivity.this, R.anim.anim_down_in2);
		if(isShow){
			searchView.setVisibility(View.VISIBLE);
			tipsView.setVisibility(View.VISIBLE);
			searchView.setAnimation(mAnimRightIn);
			tipsView.setAnimation(mAnimRightIn);
			tempView.setVisibility(View.VISIBLE);
			friendsView.setVisibility(View.INVISIBLE);
			tempView.setAnimation(mAnimDownin2);
		}
		else{
			searchView.setVisibility(View.INVISIBLE);
			tipsView.setVisibility(View.INVISIBLE);
			tempView.setVisibility(View.INVISIBLE);
			friendsView.setVisibility(View.VISIBLE);
			friendsView.setAnimation(mAnimDownIn);
		}
		
		isShow = !isShow;
		ImageView friendImageView = (ImageView)searchView.findViewById(R.id.friendImageView);
		friendImageView.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				// TODO Auto-generated method stub
				String searchStr = searchEditText.getText().toString().trim();
				if(searchStr != null){
					Intent intent = new Intent(FriendsMainActivity.this, FriendsSearchResultActivity.class);
					intent.putExtra("SearchStr", searchStr);
					startActivity(intent);
					finish();
				}
			}
		});
	}
}
